# FILE: WebDocumentNode.py
# DESC:

import random

class WebDocumentNode:

	def __init__(self, argv, customerUrl):
		self.content_ = {}
		self.content_['id'] = argv[0]
		
		if len(argv[1]) > 0:
			images = argv[1].split(' ')
			image = None
			if len(images) == 1:
				image = images[0]
			else:
				image = images[random.choice(range(0, len(images) - 1))]
				
			if image.find("http") == -1:
				image = customerUrl + image
				
			self.content_['image'] = image
		else:
			self.content_['image'] = None 
			
		self.content_['name'] = argv[2]
		self.content_['url'] = customerUrl + argv[3]
		self.content_['price'] = argv[4]

	# TODO: move to base class
	def getId(self):
		return self.content_['id']
	
	
	def getName(self):
		return self.content_['name']
	

	def getUrl(self):
		return self.content_['url']


	def getImage(self):
		return self.content_['image']


	def getPrice(self):
		return self.content_['price']

			
	# TODO: move to base class
	def getContent(self):
		return self.content_
